<template>
	<view >
		<view style="width: 100%; height:400rpx"><l-f2 ref="chart" style="width: 100%; height: 100%;"></l-f2></view>
	</view>
</template>

<script>
	// import F2 from '@antv/f2';
	import F2 from '@/uni_modules/lime-f2/components/lime-f2/f2.min.js';
	import lF2 from '@/uni_modules/lime-f2/components/lime-f2/';
	export default{
		 components: {lF2},
		 props:["list"],
		data(){
			return{
				
			}
		},
		created(){
			
		},
		mounted(){
			this.init()
			
		},
		methods:{
			init(){
				let arr= this.list
				
				let obj=[]
				for(var key in arr){
				    
					obj.push({year:key,sales:arr[key]})
				}
				if(obj.length>7){
					this.$refs.chart.init(config => {
					            const chart = new F2.Chart(config);
					            chart.source(obj);
					            chart
					                .interval()
					                .position('year*sales')
					                .color('#5B8FF9');
					            chart.render();
					            // 需要把 chart 返回
					            return chart;
					        });
				}else{
					this.$refs.chart.init(config => {
					            const chart = new F2.Chart(config);
					            chart.source(obj);
					            chart
					                .interval()
					                .position('year*sales')
					                .color('#5B8FF9');
					            chart.render();
					            // 需要把 chart 返回
					            return chart;
					        });
				}
				
			}
		}
	}
	 
	
</script>

<style>
</style>
